package bjtuoj;

import java.util.Scanner;

/**
 * ClassName: Homework_1_1
 * Description: 最大公约数 最小公倍数 : 洛谷p1029
 * date: 2021-09-25 15:48
 *
 * @author liyifan
 */
public class Homework_1_A {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x0 = scanner.nextInt();
        int y0 = scanner.nextInt();
        System.out.print(solution(x0, y0));
        scanner.close();
    }

    public static int solution(int x0, int y0){
        int res = 0;
        for(int i = 1;i <= Math.sqrt(x0 * y0); i++) {
            if ((x0 * y0) % i == 0 && gcd((x0 * y0) / i, i) == x0) {
                res++;
            }
        }
        res *= 2;
        if (x0 == y0) {
            res -= 1;
        }
        return res;
    }

    public static int gcd(int a, int b){
        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }

}
